<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
</style>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/daterangepicker.css"/>

    <title>特种·数据工厂</title>
    <link href="${pageContext.request.contextPath }/img/webLogoIcon.png"
          rel="shortcut icon">
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css"
          rel="stylesheet">

    <link href="${pageContext.request.contextPath }/css/animate.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css"
          rel="stylesheet">


    <!-- FooTable -->
    <link href="${pageContext.request.contextPath }/css/footable.core.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datepicker3.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/mypage.css"
          rel="stylesheet">
</head>

<body>

<div id="wrapper">

    <nav class="navbar-default navbar-static-side" role="navigation">
        <%request.setAttribute("LEFT", "bindding-special");%>
        <jsp:include page="../components/left.jsp" flush="true"/>
    </nav>

    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom m-b-20">
            <jsp:include page="../components/head.jsp" flush="true"/>
        </div>
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-9">
                <h2>特种</h2>
                <ol class="breadcrumb">
                    <li class="nav-main1"><a
                            href="${pageContext.request.contextPath}/admin/tosystem_overview">主页</a>
                    </li>
                    <li class="nav-main2"><a id="navigation1" href="#">招标投标</a></li>
                    <li class="active"><a>特种</a></li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                <div class="ibox float-e-margins" id="dataInfoLine"></div>
                    <div class="ibox float-e-margins">
<!--                         <div class="ibox-content"> -->
                            <!-- 下拉框 -->
<!--                             <div class="row"> -->
<!--                                 <div class="col-sm-5 m-b-xs" style="width:300px"> -->
<!--                                     省:<select id="province" class="input-sm form-control input-s-sm inline" -->
<!--                                               style="width:90px;height:35px;margin-right:10px" -->
<!--                                               onchange="provinceChange()"> -->
<!--                                     <option value="">全部</option> -->
<%--                                     <option value="1">北京</option> --%>
<!--                                 </select> -->

<!--                                     市:<select id="city" class="input-sm form-control input-s-sm inline" -->
<!--                                               style="width:90px;height:35px;margin-right:10px" onchange="cityChange()"> -->
<!--                                     <option value="">全部</option> -->
<!--                                 </select> -->
<!--                                 </div> -->
<!--                             </div> -->

<!--                             时间:<input class="select-text" id="times" -->
<!--                                       style="margin-right:10px;height: 34px;border: 1px solid #e5e6e7;border-radius: 4px;" -->
<!--                                       placeholder="选择时间"> -->


<!--                             信息类型: <select class="input-sm form-control input-s-sm inline" id="informationtype" -->
<!--                                           onchange="informationtypeChange()" -->
<!--                                           style="width:90px;height:35px;margin-right: 15px"> -->
<%--                             <option value="0">全文</option> --%>
<!--                         </select> -->

<!--                             业务类型:<select id="businessType" class="input-sm form-control input-s-sm inline" -->
<!--                                          style="width:90px;height:35px;margin-right: 15px" -->
<!--                                          onchange="businessTypeChange()"> -->
<!--                             <option value="0">全部</option> -->
<!--                         </select> -->

<!--                             行业:<select id="industry" class="input-sm form-control input-s-sm inline" -->
<!--                                        style="width:90px;height:35px;margin-right: 15px" onchange="industryChange()"> -->
<!--                             <option value="0">全部</option> -->
<!--                         </select> -->

<!--                             <div class="input-group" style="width:250px;margin-right:20px"> -->
<!--                                 <input id="keywords" type="text" class="form-control"> -->
<!--                                 <div class="input-group-btn"> -->
<!--                                     <button tabindex="-1" class="btn btn-white" type="button" onclick="searchBidding()"> -->
<!--                                         搜索 -->
<!--                                     </button> -->
<!--                                     <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button" -->
<!--                                             aria-expanded="false" style="height:34px"><span class="caret"></span> -->
<!--                                     </button> -->
<!--                                     <ul class="dropdown-menu pull-right" id="searchType"> -->
<!--                                         <li data-id="2"><a>全部</a></li> -->
<!--                                         <li data-id="0"><a>标题</a></li> -->
<!--                                         <li data-id="1"><a>正文</a></li> -->
<!--                                     </ul> -->
<!--                                 </div> -->
<!--                             </div> -->
<!--                         </div> -->


                        <div class="ibox-content">
                         <div class="input-select" style="margin-bottom: 20px">
	                               		<div class="input-selectbox">
                                            <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle" type="button"  aria-expanded="false">
                                            <i class="fa fa-bars"></i>
                                            <span id="inputSelected">全部</span></button>
                                            <ul class="dropdown-menu" id="selectlist">
                                            	<li><a onclick="setselect(this)">全部</a></li>
                                            	<li><a onclick="setselect(this)">标题</a></li>
                                                <li><a onclick="setselect(this)">省份</a></li>
                                            	<!-- <li><a onclick="setselect(this)">全部</a></li>
                                                <li><a onclick="setselect(this)">全文</a></li>
                                                <li><a onclick="setselect(this)">标题</a></li> -->
                                            </ul>
	                                        <input id="keywords" type="text" class="form-control" style="width:440px;padding-right: 42px;">
	                                        <i id="gosearch" class="fa fa-search cursearch" onclick="searchBidding()"></i>
	                                    </div>
	                                </div>
                            <div class="table-responsive">
                                <table class="table">
                                    <thead>
                                    <tr  style="background:#f5f5f6">
                                        <th>标题</th>
                                        <th>省份</th>
                                        <th>发布日期</th>
                                        <th>数据来源</th>
                                    </tr>
                                    </thead>
                                    <tbody id="tbody">
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="11" id="fenyes">
                                            <%--     <c:if test="${invites.pageCount>0}"> --%>
                                            <div class="box" id="box" style="float: right;"></div>
                                            <%--     </c:if> --%>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <jsp:include page="../components/footer.jsp" flush="true"/>
    </div>
</div>


<!-- Mainly scripts -->
<script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/moment.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/daterangepicker.min.js"></script>
<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
<script src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>

<!-- Custom and plugin javascript -->
<script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
<script src="${pageContext.request.contextPath }/js/pace.min.js"></script>


<!-- FooTable -->
<script src="${pageContext.request.contextPath }/js/footable.all.min.js"></script>
<script src="${pageContext.request.contextPath}/js/mypage.js"></script>
<script src="${pageContext.request.contextPath }/js/plugins/toastr/toastr.min.js"></script>

<!-- Page-Level Scripts -->
<script src="${pageContext.request.contextPath}/js/anychart-base.min.js"></script>
<script src="${pageContext.request.contextPath}/js/userCustom.js"></script>
<script>
	
//		折线图
	
	<% 
       String website_id = (String)request.getParameter("website_id");
     %>
    var website_id = '<%=website_id%>'
    console.log("website_id:"+website_id)
	
    let searchType = 2;
    var startTime = getToday();
    var endTime = getToday();
    
    function setselect(that){
    	let type = $(that).text();
		$('#inputSelected').html(type);
		if(type=="省份"){
			searchType=1;
		}else if(type=="标题"){
			searchType=0;
		}else if(type=="全部"){
			searchType=2;
		}
    }
    
    $(document).ready(function () {
    	var data=${nowArray};
        createLine("特种招标",1,data);
        var locale = {
            "format": 'YYYY-MM-DD',
            "separator": " - ",
            "applyLabel": "确定",
            "cancelLabel": "取消",
            "fromLabel": "起始时间",
            "toLabel": "结束时间'",
            "customRangeLabel": "自定义",
            "weekLabel": "W",
            "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
            "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            "firstDay": 1
        };
        $('#times').daterangepicker({
            'locale': locale,
            ranges: {
                '今日': [moment(), moment()],
                '昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                '最近7日': [moment().subtract(6, 'days'), moment()],
                '最近30日': [moment().subtract(29, 'days'), moment()],
                '本月': [moment().startOf('month'), moment().endOf('month')],
                '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
                    .endOf('month')
                ]
            },
            "alwaysShowCalendars": true,
            "startDate": new Date(),
            "endDate": new Date(),
            "opens": "right",
        }, function (start, end, label) {
            console.log(start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
            startTime = start.format('YYYY-MM-DD');
            endTime = end.format('YYYY-MM-DD');
            let province = $("#province option:selected").val();
            let city = $("#city option:selected").val();
            let keywords = $("#keywords").val();   // 搜索的关键词
            let informationtype = $("#informationtype option:selected").val();
            let businessType = $("#businessType option:selected").val();
            let industry = $("#industry option:selected").val();
            let data = new Object();
            data.keywords = keywords;
            data.province = province;
            data.city = city;
            data.informationtype = informationtype;
            data.businessType = businessType;
            data.industry = industry;
            data.times = startTime;
            data.timee = endTime;
            data.searchType = searchType;
            data.pageNum = 1;
            sendBiddingList(data);
        });

        setTimeout(function () {
            let data = new Object();
            data.keywords = "";
            data.province = "";
            data.city = "";
            data.informationtype = "";
            data.businessType = "";
            data.industry = "";
            data.times = startTime;
            data.timee = endTime;
            data.searchType = 2;
            data.pageNum = 1;
            sendBiddingList(data);
        }, 1500);
    });

    // 取出当前日期
    function getToday() {
        var now = new Date();
        var year = now.getFullYear(); //得到年份
        var month = now.getMonth();//得到月份
        var date = now.getDate();//得到日期
        month = month + 1;
        if (month < 10) month = "0" + month;
        if (date < 10) date = "0" + date;
        var time = "";
        time = year + "-" + month + "-" + date;
        return time;
    }

    // 搜索关键词
    function searchBidding() {
        let province = $("#province option:selected").val();
        let city = $("#city option:selected").val();
        let keywords = $("#keywords").val();   // 搜索的关键词
        let informationtype = $("#informationtype option:selected").val();
        let businessType = $("#businessType option:selected").val();
        let industry = $("#industry option:selected").val();
        let data = new Object();
        data.keywords = keywords;
        data.province = province;
        data.city = city;
        data.informationtype = informationtype;
        data.businessType = businessType;
        data.industry = industry;
        data.times = startTime;
        data.timee = endTime;
        data.searchType = searchType;
        data.pageNum = 1;
        sendBiddingList(data);
    }

    // 请求列表数据
    function sendBiddingList(data) {
    	data.website_id = website_id;
    	console.log("----------"+website_id);
    	$('#tbody').html('<div><h1 style="text-align:right;">加载数据中......</h1></div>')
        $.ajax({
            url: "${pageContext.request.contextPath}/bidding/getSpecialList",
            type: "POST",
            dataType: "json",
            contentType: 'application/json;charset=UTF-8',
            data:JSON.stringify(data),
            success: function (res) {
                console.log("请求列表数据成功！");
                console.log(res);
                groupData(res);
            },
            error: function (err) {
                console.log("请求列表数据失败！");
                console.log(err);
            }
        })
    }

    // 组装数据
    function groupData(res) {
        let totalCount = res.totalData;
        let pageNum = res.page;
        let pageCount = res.totalPage;
        let inviteList = res.inviteList;
        if (pageCount > 500) {
            pageCount = 500;
        }
        paging(totalCount, pageCount, pageNum);
        let listData = res.list;
        let StrAll = '';
        if (listData.length > 0) {
            for (let i = 0; i < listData.length; i++) {
                let listDataObj = listData[i];
                let city = listDataObj.city;
                let biaoprice = listDataObj.biaoprice;
                let industry = listDataObj.industry;
                let originalwebsite = listDataObj.originalwebsite;
                let originalurl = listDataObj.originalurl;
                let numberid = listDataObj.numberid;
                let informationtype = listDataObj.informationtype;
                let sourceplatform = listDataObj.sourceplatform;
                let province = listDataObj.province;
                let datasource = listDataObj.datasource;
                let detailurl = listDataObj.detailurl;
                let businessType = listDataObj.businessType;
                let publish_date = listDataObj.publish_time;
                let title = listDataObj.title;
                let article_public_id = listDataObj.article_public_id;
                publish_date=/\d{4}-\d{1,2}-\d{1,2}/g.exec(publish_date);

                <%--let Str0 = '<tr><td>' + publish_date + '</td><td>' + datasource--%>
                <%--+ '</td><td>' + province + '</td><td>' + city--%>
                <%--+ '</td><td>' + sourceplatform + '</td><td>'--%>
                <%--+ businessType + '</td><td>' + informationtype--%>
                <%--+ '</td><td></td><td><a   target="_blank" href="${pageContext.request.contextPath}/bidding/getInformationtypeDeatil?article_public_id=' + article_public_id + '">' + title + '</a></td><td>' + numberid--%>
                <%--+ '</td><td>' + biaoprice + '</td></tr>';--%>

                if (province == "央企招投标") {
                    province = "中央";
                }
                for(let i=0;i<province.length;i++){
                	if(!isNaN(Number(province.substring(i, i+1)))){
                		province=""
                		break
                	}
                }
                let Str0 = '<tr><td title="'+ title +'"><a class="overtext" style="width:600px;" target="_blank"  href="${pageContext.request.contextPath}/bidding/getInformationtypeDeatil?article_public_id=' + article_public_id + '">' + title
                    + '</a></td><td>' + province + '</td><td>' + publish_date + '</td><td>' + datasource + '</td></tr>';
                StrAll += Str0;
            }
        } else {
            StrAll = '<tr><td  colspan="5" style="text-align: center">暂无数据，换个搜索条件试试！</td></tr>';
        }
        $("#tbody").html(StrAll);
    }

    function paging(totalData, totalPage, pagenum) {
        $('#box').paging({
            initPageNo: pagenum, // 初始页码
            totalPages: totalPage, //总页数
            totalCount: '合计' + totalData + '条数据', // 条目总数
            slideSpeed: 600, // 缓动速度 单位毫秒
            jump: true, //是否支持跳转
            callback: function (page) {
                // 回调函数
            }
        });
    }

    function JumpToPage(pagenum) {
        if (pagenum > 500) {
            pagenum = 500
        }
        let province = $("#province option:selected").val();
        let city = $("#city option:selected").val();
        let keywords = $("#keywords").val();   // 搜索的关键词
        let informationtype = $("#informationtype option:selected").val();
        let businessType = $("#businessType option:selected").val();
        let industry = $("#industry option:selected").val();
        let data = new Object();
        data.keywords = keywords;
        data.province = province;
        data.city = city;
        data.informationtype = informationtype;
        data.businessType = businessType;
        data.industry = industry;
        data.times = startTime;
        data.timee = endTime;
        data.searchType = searchType;
        data.pageNum = pagenum;
        sendBiddingList(data);
    }
</script>
</body>

</html>
